import 'package:flutter/material.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ListView"),
      ),
      body: MyHomePageBody(),
    );
  }
}

class MyHomePageBody extends StatelessWidget {
  const MyHomePageBody({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      itemCount: 1000,
      itemBuilder: (context, index) {
        return GestureDetector(
          child: ListTile(
            title: Text("hello world ${index}"),
            leading: Icon(Icons.people),
            trailing: Icon(Icons.delete),
            subtitle: Text("基本ListView"),
          ),
        );
      },
      separatorBuilder: (context, index) {
        return Divider(
          color: Colors.grey,
          height: 10,
          indent: 20,
          endIndent: 20,
          thickness: 3,
        );
      },
    );
  }
}

Widget ListViewDemo2() {
  return ListView.builder(
      itemCount: 1000,
      itemExtent: 55,
      itemBuilder: (context, index) {
        return ListTile(
          title: Text("hello world ${index}"),
          leading: Icon(Icons.people),
          trailing: Icon(Icons.delete),
          subtitle: Text("基本ListView"),
        );
      });
}

Widget ListViewDome1() {
  return ListView(
    scrollDirection: Axis.vertical,
    children: List.generate(100, (index) {
      return ListTile(
        title: Text("hello world ${index}"),
        leading: Icon(Icons.people),
        trailing: Icon(Icons.delete),
        subtitle: Text("基本ListView"),
      );
    }),
  );
}
